<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Filter flags</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="filter.filters.misc.html">« Other filters</a></li>
      <li style="float: right;"><a href="filter.constants.html">预定义常量 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="filter.filters.html">Types of filters</a></li>
    <li>Filter flags</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="filter.filters.flags" class="section">
  <h2 class="title">Filter flags</h2>
  
  <p class="para">
   <table class="doctable table">
    <caption><strong>List of filter flags</strong></caption>
    
     <thead>
      <tr>
       <th>ID</th>
       <th>Used with</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td><strong><code>FILTER_FLAG_STRIP_LOW</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_ENCODED</code></strong>,
        <strong><code>FILTER_SANITIZE_SPECIAL_CHARS</code></strong>,
        <strong><code>FILTER_SANITIZE_STRING</code></strong>,
        <strong><code>FILTER_UNSAFE_RAW</code></strong>
       </td>
       <td>
        Strips characters that have a numerical value &lt;32.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_STRIP_HIGH</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_ENCODED</code></strong>,
        <strong><code>FILTER_SANITIZE_SPECIAL_CHARS</code></strong>,
        <strong><code>FILTER_SANITIZE_STRING</code></strong>,
        <strong><code>FILTER_UNSAFE_RAW</code></strong>
       </td>
       <td>
        Strips characters that have a numerical value &gt;127.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_STRIP_BACKTICK</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_ENCODED</code></strong>,
        <strong><code>FILTER_SANITIZE_SPECIAL_CHARS</code></strong>,
        <strong><code>FILTER_SANITIZE_STRING</code></strong>,
        <strong><code>FILTER_UNSAFE_RAW</code></strong>
       </td>
       <td>
        Strips backtick characters.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_ALLOW_FRACTION</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_NUMBER_FLOAT</code></strong>
       </td>
       <td>
        Allows a period (<code class="literal">.</code>) as a fractional separator in
        numbers.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_ALLOW_THOUSAND</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_NUMBER_FLOAT</code></strong>,
        <strong><code>FILTER_VALIDATE_FLOAT</code></strong>
       </td>
       <td>
        Allows a comma (<code class="literal">,</code>) as a thousands separator in
        numbers.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_ALLOW_SCIENTIFIC</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_NUMBER_FLOAT</code></strong>
       </td>
       <td>
        Allows an <code class="literal">e</code> or <code class="literal">E</code> for scientific
        notation in numbers.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_NO_ENCODE_QUOTES</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_STRING</code></strong>
       </td>
       <td>
        If this flag is present, single (<code class="literal">&#039;</code>) and double
        (<code class="literal">&quot;</code>) quotes will not be encoded.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_ENCODE_LOW</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_ENCODED</code></strong>,
        <strong><code>FILTER_SANITIZE_STRING</code></strong>,
        <strong><code>FILTER_UNSAFE_RAW</code></strong>
       </td>
       <td>
        Encodes all characters with a numerical value &lt;32.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_ENCODE_HIGH</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_ENCODED</code></strong>,
        <strong><code>FILTER_SANITIZE_SPECIAL_CHARS</code></strong>,
        <strong><code>FILTER_SANITIZE_STRING</code></strong>,
        <strong><code>FILTER_UNSAFE_RAW</code></strong>
       </td>
       <td>
        Encodes all characters with a numerical value &gt;127.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_ENCODE_AMP</code></strong></td>
       <td>
        <strong><code>FILTER_SANITIZE_STRING</code></strong>,
        <strong><code>FILTER_UNSAFE_RAW</code></strong>
       </td>
       <td>
        Encodes ampersands (<code class="literal">&amp;</code>).
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_NULL_ON_FAILURE</code></strong></td>
       <td>
        any <a href="filter.filters.validate.html" class="link"><strong><code>FILTER_VALIDATE_*</code></strong></a>
       </td>
       <td>
        Returns <strong><code>null</code></strong> for unrecognized values.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_ALLOW_OCTAL</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_INT</code></strong>
       </td>
       <td>
        Regards inputs starting with a zero (<code class="literal">0</code>) as octal
        numbers. This only allows the succeeding digits to be
        <code class="literal">0-7</code>.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_ALLOW_HEX</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_INT</code></strong>
       </td>
       <td>
        Regards inputs starting with <code class="literal">0x</code> or
        <code class="literal">0X</code> as hexadecimal numbers. This only allows
        succeeding characters to be <code class="literal">a-fA-F0-9</code>.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_EMAIL_UNICODE</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_EMAIL</code></strong>
       </td>
       <td>
        Allows the local part of the email address to contain Unicode characters.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_IPV4</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_IP</code></strong>
       </td>
       <td>
        Allows the IP address to be in IPv4 format.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_IPV6</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_IP</code></strong>
       </td>
       <td>
        Allows the IP address to be in IPv6 format.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_NO_PRIV_RANGE</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_IP</code></strong>
       </td>
       <td>
        <p class="para">
         Fails validation for the following private IPv4 ranges:
         <code class="literal">10.0.0.0/8</code>, <code class="literal">172.16.0.0/12</code> and
         <code class="literal">192.168.0.0/16</code>.
        </p>
        <p class="para">
         Fails validation for the IPv6 addresses starting with
         <code class="literal">FD</code> or <code class="literal">FC</code>.
        </p>
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_NO_RES_RANGE</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_IP</code></strong>
       </td>
       <td>
        <p class="para">
        Fails validation for the following reserved IPv4 ranges:
        <code class="literal">0.0.0.0/8</code>, <code class="literal">169.254.0.0/16</code>,
        <code class="literal">127.0.0.0/8</code> and <code class="literal">240.0.0.0/4</code>.
        </p>
        <p class="para">
         Fails validation for the following reserved IPv6 ranges:
         <code class="literal">::1/128</code>, <code class="literal">::/128</code>,
         <code class="literal">::ffff:0:0/96</code> and <code class="literal">fe80::/10</code>.
        </p>
        <p class="para">
         These are the ranges that are marked as Reserved-By-Protocol in
         <a href="http://www.faqs.org/rfcs/rfc6890" class="link external">&raquo;&nbsp;RFC 6890</a>.
        </p>
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_GLOBAL_RANGE</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_IP</code></strong>
       </td>
       <td>
        <p class="para">
         Fails validation for non global IPv4/IPv6 ranges as found in
         <a href="http://www.faqs.org/rfcs/rfc6890" class="link external">&raquo;&nbsp;RFC 6890</a> with the
         <code class="literal">Global</code> attribute being <code class="literal">False</code>.
        </p>
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_SCHEME_REQUIRED</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_URL</code></strong>
       </td>
       <td>
        Requires the <abbr title="Uniform Resource Locator">URL</abbr> to contain a scheme part.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_HOST_REQUIRED</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_URL</code></strong>
       </td>
       <td>
        Requires the <abbr title="Uniform Resource Locator">URL</abbr> to contain a host part.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_PATH_REQUIRED</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_URL</code></strong>
       </td>
       <td>
        Requires the <abbr title="Uniform Resource Locator">URL</abbr> to contain a path part.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FLAG_QUERY_REQUIRED</code></strong></td>
       <td>
        <strong><code>FILTER_VALIDATE_URL</code></strong>
       </td>
       <td>
        Requires the <abbr title="Uniform Resource Locator">URL</abbr> to contain a query string.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_REQUIRE_SCALAR</code></strong></td>
       <td>
       </td>
       <td>
        Requires the value to be scalar.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_REQUIRE_ARRAY</code></strong></td>
       <td>
       </td>
       <td>
        Requires the value to be an array.
       </td>
      </tr>

      <tr>
       <td><strong><code>FILTER_FORCE_ARRAY</code></strong></td>
       <td>
       </td>
       <td>
        If the value is a scalar, it is treated as array with the scalar value
        as only element.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>

  <div class="simplesect">
   <h3 class="title">更新日志</h3>
   <p class="para">
    <table class="doctable informaltable">
     
      <thead>
       <tr>
        <th>版本</th>
        <th>说明</th>
       </tr>

      </thead>

      <tbody class="tbody">
       <tr>
        <td>8.2.0</td>
        <td>
         <strong><code>FILTER_FLAG_GLOBAL_RANGE</code></strong> as a flag to
         <strong><code>FILTER_VALIDATE_IP</code></strong> has been added.
        </td>
       </tr>

       <tr>
        <td>7.3.0</td>
        <td>
         The explicit usage of <strong><code>FILTER_FLAG_SCHEME_REQUIRED</code></strong>
         and <strong><code>FILTER_FLAG_HOST_REQUIRED</code></strong> has been deprecated.
        </td>
       </tr>

       <tr>
        <td>7.1.0</td>
        <td>
         <strong><code>FILTER_FLAG_EMAIL_UNICODE</code></strong> has been added.
        </td>
       </tr>

      </tbody>
     
    </table>

   </p>
  </div>
 </div></div></div></body></html>